import 'package:get/get.dart';

class NotificationItem {
  final String id;
  final String title;
  final String content;
  final String createdAt;

  NotificationItem({
    required this.id,
    required this.title,
    required this.content,
    required this.createdAt,
  });

  // 工厂方法：从 Map 转为 NotificationItem
  factory NotificationItem.fromJson(Map<String, dynamic> json) {
    return NotificationItem(
      id: json['id'] ?? '',
      title: json['title'] ?? '',
      content: json['content'] ?? '',
      createdAt: json['createdAt'] ?? '',
    );
  }
}

class NotifyDetailMap {
  final String id;
  final String title;
  final String content;
  final String creatorName;
  final String createdAt;

  NotifyDetailMap({
    required this.id,
    required this.title,
    required this.content,
    required this.creatorName,
    required this.createdAt,
  });

  // 工厂方法：从 Map 转为 NotifyDetailMap
  factory NotifyDetailMap.fromJson(Map<String, dynamic> json) {
    return NotifyDetailMap(
      id: json['id'] ?? '',
      title: json['title'] ?? '',
      content: json['content'] ?? '',
      creatorName: json['creatorName'] ?? '',
      createdAt: json['createdAt'] ?? '',
    );
  }
}

class HomeState {
  // 导航数据
  final List navList = [
    {
      'title': '我的房屋',
      'icon': 'images/house_nav_icon@2x.png',
    },
    {
      'title': '我的报修',
      'icon': 'images/repair_nav_icon@2x.png',
    },
    {
      'title': '访客登记',
      'icon': 'images/visitor_nav_icon@2x.png',
    }
  ].obs;

//列表数据
  final RxList<NotificationItem> notifyList = <NotificationItem>[].obs;

// 详情数据
  final Rx<NotifyDetailMap> notifyDetail = Rx<NotifyDetailMap>(NotifyDetailMap(
      id: '', title: '', content: '', creatorName: '', createdAt: ''));
}
